package com.clw.utils;

import java.util.List;

/**
 * Created by Administrator on 2017-10-12.
 */
public class StringUtils {
    /**
     * 判断对象是否为空
     *
     * @param str
     * @return
     */
    public static boolean isNotEmpty(Object str) {
        boolean flag = true;
        if (str != null && !str.equals("")) {
            if (str.toString().length() > 0) {
                flag = true;
            }
        } else {
            flag = false;
        }
        return flag;
    }

    public static boolean isEmpty(Object object) {
        if (object == null) {
            return (true);
        }
        if (object.equals("")) {
            return (true);
        }
        if (object.equals("null")) {
            return (true);
        }
        return (false);
    }

    public static String join(List<String> list, String s) {
        if(list==null){
            return null;
        }
        StringBuilder result = new StringBuilder();
        boolean first = true;
        for(String string :list) {
            if(first) {
                first=false;
            }else{
                result.append(s);
            }
            result.append(string);
        }
        return result.toString();
    }
}
